<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .xianshi {
            width: 700px;
            height: 100px;
            border: 2px solid red;
            display: flex;
            text-align: center;
        }

        .box .lian {
            margin-left: 12px;
            margin-top: 5px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="xianshi"></div>
        <button class="shang">上一页</button>
        <button class="xia">下一页</button>
        <span>1/4</span>
    </div>
</body>

</html>
<script src="./ajax.js"></script>
<script>
    var page = 1
    function xuanran() {
        ajax('get', 'https://yantianfeng.com/api/emotion', { page: page, count: 10 }).then((data) => {
            var str = data.emotions.map((item) => {
                return `<div class="lian"><div><img src="${item.url}"></div><div>${item.title}</div></div>`
            }).join('')
            document.querySelector('.box .xianshi').innerHTML = str
        })
        document.querySelector('.box span').innerHTML = `${page}/4`
    }
    xuanran()
    document.querySelector('.box .shang').onclick = function () {
        if (page > 1) {
            page--
            xuanran()
        }
    }
    document.querySelector('.box .xia').onclick = function () {
        if (page < 4) {
            page++
            xuanran()
        }
    }
</script>